package tech.aistar.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tech.aistar.entity.Message;

import java.util.List;

public interface MessageMapper {
    @Select("select * from message where register_id=#{registerId}")
    List<Message> selectAll(Integer registerId);

    @Delete("delete from message where id=#{id}")
    int deleteById(Integer id);

    @Update("update message set message_state='已读' where id=#{id}")
    int updateStateById(Integer id);

    @Select("select * from message where register_id=#{registerId} and message_state='未读'")
    List<Message> selectByState(Integer registerId);

    @Insert("insert into message(register_id,message_content,message_state,response_time) values(#{registerId},#{messageContent},'未读',#{responseTime})")
    int insertAll(Message message);

}
